{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "url = 'http://angelimg.spbeen.com/ang/10200'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "headers = {\n",
    "    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = requests.get(url, headers=headers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\\n\\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\\n\\n<head>\\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\\n\\n    <title>孙俪最新单曲《感知成长的神奇》MV今日正式公布，作为智慧辣妈的典型代表，孙俪在MV中展现了一位懂得尊重、理解宝宝成长的妈妈，进入宝宝的世界，一起感知成长的神奇经历。整个MV的拍摄画面活泼有趣，产后复出的孙俪状态大好，与两个宝贝的互动轻松快乐，全程演绎满分辣妈。</title>\\n    <meta name=\"keywords\" content=\"影视剧照 娱乐 定妆照 \">\\n    <meta name=\"description\" content=\"孙俪最新单曲《感知成长的神奇》MV今日正式公布，作为智慧辣妈的典型代表，孙俪在MV中展现了一位懂得尊重、理解宝宝成长的妈妈，进入宝宝的世界，一起感知成长的神奇经历。整个MV的拍摄画面活泼有趣，产后复出的孙俪状态大好，与两个宝贝的互动轻松快乐，全程演绎满分辣妈。。http://angelimg.spbeen.com\">\\n    \\n<meta name=\\'baidu_union_verify\\' content=\\'f56b6e530bdc22de55f578c1a0ef07ea\\'>\\n\\n    <link rel=\"alternate\" media=\"only screen and(max-width: 640px)\" href=\"http://m.angelimg.com/mm/1393/7\">\\n    <link href=\"http://angelimg.spbeen.com/static/css/angelimg.css\" rel=\"stylesheet\" type=\"text/css\">\\n\\n</head>\\n\\n<body>\\n    <div class=\"topbar\" style=\"z-index:100;\">\\n        <div class=\"subnav\">\\n            <a href=\"http://angelimg.spbeen.com/\" style=\"margin-right: 30px;\"><h2 style=\"color:#f28bb9;\">斯图</h2></a>\\n              <a href=\"http://angelimg.spbeen.com/\">所有</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/1\">写真</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/2\">生活</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/3\">影视剧照</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/4\">活动现场</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/5\">广告</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/6\">娱乐</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/7\">古装</a>\\n            \\n              <a href=\"http://angelimg.spbeen.com/tag/8\">定妆照</a>\\n            \\n        </div>\\n  </div>\\n    <div class=\"main\">\\n        <div class=\"article\">\\n            <h2>孙俪最新单曲《感知成长的神奇》MV...【1】</h2>\\n            <div class=\"info\">\\n                <i>发表于: 2018-04-13</i>\\n                <i>图片来源网络，如若侵权请联系删除</i>\\n            </div>\\n            <div class=\"content\" id=\"content\">\\n                <a href=\"/ang/10200/2\">\\n                    <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/WFHX20XiomBDye2nguRi279596/kJf25S4UxYP5M4KYOOQp279596-rDZqGt.jpg\" alt=\"孙俪最新单曲《感知成长的神奇》MV今日正式公布，作为智慧辣妈的典型代表，孙俪在MV中展现了一位懂得尊重、理解宝宝成长的妈妈，进入宝宝的世界，一起感知成长的神奇经历。整个MV的拍摄画面活泼有趣，产后复出的孙俪状态大好，与两个宝贝的互动轻松快乐，全程演绎满分辣妈。 第1张\">\\n                </a>\\n            </div>\\n            <div class=\"page\" id=\"page\">\\n            \\n\\n                \\n\\n                \\n\\n                    \\n                        <em>1</em>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/2\">2</a>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/3\">3</a>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/4\">4</a>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/5\">5</a>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/6\">6</a>\\n                    \\n                \\n\\n                    \\n                        <a href=\"/ang/10200/7\">7</a>\\n                    \\n                \\n\\n                \\n                <a href=\"/ang/10200/2\" class=\"ch next\">下一张</a>\\n                    \\n            <a  class=\"total num\">共10页</a>\\n\\n            </div>\\n            <div class=\"other\">\\n                <div class=\"tags\">\\n                    \\n                    <a href=\"http://angelimg.spbeen.com/tag/3\">影视剧照</a>\\n                    \\n                    <a href=\"http://angelimg.spbeen.com/tag/6\">娱乐</a>\\n                    \\n                    <a href=\"http://angelimg.spbeen.com/tag/8\">定妆照</a>\\n                    \\n                </div>\\n\\n\\n\\n\\n\\n            </div>\\n            <div class=\"hot\">\\n                <dl id=\"hot\">\\n                    <dt>美图推荐</dt>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/711\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/6aU7PsSiRMiLAH6r3mRC306118/8eb4FgUou7KsEBvgoai8306118-DnKdh4.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"16日，电影《建军大业》发布会举行，刘烨、朱亚文、欧豪、白客等亮相。\">16日，电影《建军大业》发布会举行...</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/1328\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/Ovyl4NmnThvGzi3YnFkf307336/mrgsK1FH3U4k7lLuJ2B23ea3e6cda6202e240e487babc328a570.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"董洁封面大片曝光 再现《如懿传》的深宫绮梦\">董洁封面大片曝光 再现《如懿传》的...</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/4954\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/56B3gxuj1hEg5MNg8DPX296423/eJ8I0ZgeF8LODO1e1DM7296423-XzxiFg.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"芈月传樊少使剧照\">芈月传樊少使剧照</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/5958\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/3flMz65aOAedM1pRC3o7292623/OsXrxqSu8znm21sJ1YyV292623-Ycfn5u.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"《爸爸去哪儿》第五站湖南遂宁站将添新成员，现年“三十出头”的王宝强与女儿娜娜将作为特约常驻嘉宾加盟。\">《爸爸去哪儿》第五站湖南遂宁站将添...</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/9094\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/rJsVc48sTPxZj7Tng5N2274938/rH1VGwhKjGURWCZKBqk1274938-wrGyK5.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"近日，张皓然新专辑《小时代》造型曝光，主打歌的服装造型及MV拍摄风格都是向自己一直欣赏的艺术大师草间弥生致敬。黑白主色引领波点潮流。\">近日，张皓然新专辑《小时代》造型曝...</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/770\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/iaN2c9R9t3MnzwI30R1F279569/zWCS9gADATuhvq3ALhLq279569-LXPZXb.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"美国音乐会明星争先抢镜 女星穿透视装抢镜\">美国音乐会明星争先抢镜 女星穿透视装抢镜</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/7478\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/NNJ9ofx3MC9KdhOdj4s0286448/b5agwVndYTw6ESH5Ookg17-286448-EdlxgV.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"近日，刘雨欣受杂志邀约拍摄时尚大片，以农场为背景，或身穿飘逸长裙站立或平躺在草堆中，森女装扮宛若纯情洛丽塔，恬淡可人。\">近日，刘雨欣受杂志邀约拍摄时尚大片...</a>\\n                    </dd>\\n                    \\n                    <dd>\\n                        <a href=\"http://angelimg.spbeen.com/ang/9643\" target=\"_blank\">\\n                            <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/ThQTmiB3t3GNm4L84UIa276834/g8O4sTVubgy79n9S31H4276834-A9A6qJ.jpg\" style=\"width: 100%;height: 87%;object-fit: cover;\"  alt=\"后会无期终极预告 文艺颓废气息浓重\">后会无期终极预告 文艺颓废气息浓重</a>\\n                    </dd>\\n                    \\n\\n                </dl>\\n            </div>\\n\\n\\n\\n        </div>\\n        <div class=\"sidebar\">\\n\\n\\n\\n\\n\\n\\n\\n            <div class=\"baidu250\" id=\"baidu250\"></div>\\n            <dl class=\"hot\">\\n                <dt>\\n                    <h3>热门美图</h3>\\n                </dt>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/5434\" target=\"_blank\">上周五晚节目播出后一段几秒钟的预告...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/2463\" target=\"_blank\">由爱奇艺出品、欢娱影视承制，丁墨同...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/596\" target=\"_blank\">近日，韩国男团IMFACT携手bn...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/7228\" target=\"_blank\">贾青冷艳写真 小露蛮腰展身姿</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/10498\" target=\"_blank\">近日，女星关悦为《ELLEMEN睿...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/1192\" target=\"_blank\">10月8日，黄晓明杨颖大婚，内场综...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/1544\" target=\"_blank\">由“槿汐姑姑”孙茜、李泰、汤晶媚、...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/8313\" target=\"_blank\">硬汉黄志忠前不久自驾来到北国边境草...</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/8760\" target=\"_blank\">景甜优雅登杂志 透视蕾丝秀美背</a>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/9780\" target=\"_blank\">袁成杰运动写真 尽显鬼马精神</a>\\n                </dd>\\n                \\n\\n            </dl>\\n            <dl class=\"like\">\\n                <dt>\\n                    <h3>网友最爱</h3>\\n                </dt>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/8089\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/OhQnvXP1fz1QRJ8eZlXP283926/OjhGci2ppjVgkUipUGCt283926-ll2qQG.jpg\" alt=\" 日前，有“跑男女神”之称的亚洲著名女星Angelababy（杨颖）宣布将担任某电子竞技大赛形象代言人。baby凭借美丽的形象和精湛的演技，俘获了无数粉丝的心，被公认为影视圈“女神”。Angelababy被公认为影视圈女神，而在《奔跑吧，兄弟》中的惊艳演出更让其人气直线飙升，同时她也酷爱电竞游戏，与游戏行业有深厚的不解之缘。\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/8089\" target=\"_blank\"> 日前，有“跑男女神”之称的亚洲著...</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/10433\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/QzU2mPHA4AR8xntgS6Yg307121/rQyWBxgSoYkBcfUsvwQW307121-Fceozd.jpg\" alt=\" 近日，凭借综艺《演员的诞生》大热的演员凌潇肃， 曝光了一组质感写真。照片中，凌潇肃演绎了不同风格的造型，举手投足之间散发出满满的男人魅力。粉丝看后纷纷表示：“凌潇肃帅啊，行走的模特！”\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/10433\" target=\"_blank\"> 近日，凭借综艺《演员的诞生》大热...</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/3300\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/kJkqngfnEAObjMkfavGP302414/tj4UtSuaMibVztkU33dRQ2D7EE.jpg\" alt=\"理发师陶德安东尼·霍普剧照\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/3300\" target=\"_blank\">理发师陶德安东尼·霍普剧照</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/3243\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/pvTSfTR8NNeyABMkc4Bg302743/S5gfuc8d3P0DFJyC6LsMuAMF1E.jpg\" alt=\"一吻定情2013日版松本裕子剧照\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/3243\" target=\"_blank\">一吻定情2013日版松本裕子剧照</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/3512\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/i5dYaUjX12xbKgZcMSAF301751/h2xfDddBQzRDxNjUJ70C301751-tnAMDk.jpg\" alt=\"上瘾白洛因剧照\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/3512\" target=\"_blank\">上瘾白洛因剧照</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/7922\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/sSa1NyZu1IQfs4k5vocV285162/39vuFzM7kZh1RwdEcUCy26-285162-L5hEAA.jpg\" alt=\"电视剧《何以笙箫默》改编自顾漫同名小说，主要讲述何以琛和赵默笙一段年少时的爱恋牵出一生的纠缠，一个执着于等待和相爱的故事。片方再发主题为“重逢幸福”的全新定制款海报，为本周五即将在深圳全新开播的无删减版预热。\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/7922\" target=\"_blank\">电视剧《何以笙箫默》改编自顾漫同名...</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/10240\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/TTao4m7zZtIX6N17dd4s279737/jfDSJJAWeHrzvtBYpEvg279737-JjE2jI.jpg\" alt=\"安心亚将于19日发行个人第三张专辑《在一起With You》，而18日也刚好是她满29岁生日，虽然她早就说逢九不庆祝，但她所属＂美妙音乐＂还是端出一个红色法拉利超跑蛋糕帮她庆生，预祝安心亚发片像这台法拉利“一路长红”。\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/10240\" target=\"_blank\">安心亚将于19日发行个人第三张专辑...</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/7786\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/jVezvKsVWct3quPO7OrG285351/RWQQ4cHGoKsy2lba2y0N30-285351-bBrEzZ.jpg\" alt=\"陈丹婷身穿个性的COS装，将游戏中的甄姬人物演绎得淋漓精致，尽显甜美小女人气息。\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/7786\" target=\"_blank\">陈丹婷身穿个性的COS装，将游戏中...</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/9755\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/UtiMNOPfWcmvF1O2IVqw277127/KwO5LgXyGCpi4xRjrSRm277127-JOy0MN.jpg\" alt=\"严宽商务写真 黑超遮面尽显冷峻\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/9755\" target=\"_blank\">严宽商务写真 黑超遮面尽显冷峻</a>\\n                    </span>\\n                </dd>\\n                \\n                <dd>\\n                    <a href=\"http://angelimg.spbeen.com/ang/10086\" target=\"_blank\">\\n                        <img class=\"blur\" src=\"http://image.angelimg.spbeen.com/00000mx00000/dgc7n9G1ZA1FQN15EiSP278965/aszo1oI3EufuaYlFsux4278965-bQC81R.jpg\" alt=\" 近日，杜若溪以略显职业气息的造型拍摄了一组时尚写真大片，身为年代戏常客的她此刻瞬间回归都市丽人，长发利落束起扎作马尾，黑色皮衣与橙色西装的穿搭干练飒爽，神色之间气场十足，流露出满满的御姐范儿。由杜若溪主演的电视剧《勇敢的心》正在四大卫视热播。\" style=\"height: 90%;width: 30%;object-fit: cover;\">\\n                    </a>\\n                    <span>\\n                        <a href=\"http://angelimg.spbeen.com/ang/10086\" target=\"_blank\"> 近日，杜若溪以略显职业气息的造型...</a>\\n                    </span>\\n                </dd>\\n                \\n            </dl>\\n\\n\\n        </div>\\n    <div style=\"clear: both;\"></div>\\n    </div>\\n\\n\\n    \\n\\n    <div class=\"mm\">\\n  <span><h3>友情链接:</h3></span>\\n    \\n    <span>\\n          <a href=\"http://angelimg.spbeen.com\" target=\"_blank\"><h3>斯图</h3></a>\\n    </span>\\n    \\n\\n</div>\\n\\n    <div class=\"footer\">\\n    <p>\\n        <span>@2017 斯图 WebSite | <script src=\"https://s19.cnzz.com/z_stat.php?id=1274169188&web_id=1274169188\" language=\"JavaScript\"></script></span>\\n        <span>Link Email:suanmin1997519@163.com</span>\\n    </p>\\n</div>\\n\\n</body>\\n\\n</html>'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from lxml import etree"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "html = etree.HTML(response.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/ang/10200/2',\n",
       " '/ang/10200/3',\n",
       " '/ang/10200/4',\n",
       " '/ang/10200/5',\n",
       " '/ang/10200/6',\n",
       " '/ang/10200/7',\n",
       " '/ang/10200/2']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "html.xpath('.//div[@id=\"page\"]/a/@href')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'http://angelimg.spbeen.com'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "next_links = html.xpath('.//div[@id=\"page\"]/a/@href')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/ang/10200/2',\n",
       " '/ang/10200/3',\n",
       " '/ang/10200/4',\n",
       " '/ang/10200/5',\n",
       " '/ang/10200/6',\n",
       " '/ang/10200/7',\n",
       " '/ang/10200/2']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "next_links"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://angelimg.spbeen.com/ang/10200/2\n",
      "http://angelimg.spbeen.com/ang/10200/3\n",
      "http://angelimg.spbeen.com/ang/10200/4\n",
      "http://angelimg.spbeen.com/ang/10200/5\n",
      "http://angelimg.spbeen.com/ang/10200/6\n",
      "http://angelimg.spbeen.com/ang/10200/7\n",
      "http://angelimg.spbeen.com/ang/10200/2\n"
     ]
    }
   ],
   "source": [
    "for link in next_links:\n",
    "    print(base_url + link)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "next_link = html.xpath('.//div[@id=\"page\"]/a[contains(@class, \"next\")]/@href')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/ang/10200/2']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "next_link"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_next_link(url):\n",
    "    ## 给定一个链接，返回下一个链接\n",
    "    resp = requests.get(url, headers=headers)\n",
    "    ## 将拿到的响应解析一下，然后就得到了html对象\n",
    "    html = etree.HTML(resp.text)\n",
    "    next_link = html.xpath('.//div[@id=\"page\"]/a[contains(@class, \"next\")]/@href')\n",
    "    if next_link:\n",
    "        base_url = 'http://angelimg.spbeen.com'\n",
    "        next_url = base_url + next_link[0]\n",
    "        return next_url\n",
    "    else:\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'http://angelimg.spbeen.com/ang/10200/2'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://angelimg.spbeen.com/ang/10200'\n",
    "get_next_link(url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://angelimg.spbeen.com/ang/10200/2\n",
      "http://angelimg.spbeen.com/ang/10200/3\n",
      "http://angelimg.spbeen.com/ang/10200/4\n",
      "http://angelimg.spbeen.com/ang/10200/5\n",
      "http://angelimg.spbeen.com/ang/10200/6\n",
      "http://angelimg.spbeen.com/ang/10200/7\n",
      "http://angelimg.spbeen.com/ang/10200/8\n",
      "http://angelimg.spbeen.com/ang/10200/9\n",
      "http://angelimg.spbeen.com/ang/10200/10\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "import requests\n",
    "from lxml import etree\n",
    "\n",
    "url = 'http://angelimg.spbeen.com/ang/10200'\n",
    "while True:\n",
    "    url = get_next_link(url)\n",
    "    if not bool(url):\n",
    "        break\n",
    "    print(url)\n",
    "    time.sleep(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
